import { getShopInfo } from '../../../api/goods.js';

Page({
  /**
   * 页面的初始数据
   */
  data: {
    searchValue: '',
    searchList: [],
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},
  async searchChange(e) {
    const res = await getShopInfo();
    const data = res.map((t) => {
      const regex = new RegExp(e.detail.value, 'g');
      const tag = t.replace(regex, (match) => {
        return `<span class="high-light">${match}</span>`;
      });
      return {
        keyword: t,
        tag,
      };
    });
    // console.log('data',data);
    this.setData({
      searchList: data || [],
    });
  },
  runDSearch(e) {
    const {keyword} = e.currentTarget.dataset
    wx.setStorageSync('searchKeyword', keyword)

    wx.navigateTo({
      url: '/pages/goods/dSearch/index',
    })
  }
});
